﻿
using System;
namespace __Able.Network.Connection
{
    /// <summary>
    /// 连接策略
    /// </summary>
    public class ConnectionPolicy
    {
        /// <summary>
        /// 通道
        /// </summary>
        private Channel channel;
        /// <summary>
        /// 连接ID
        /// </summary>
        /// <value></value>
        public string connectId { get; private set; }

        public ConnectionPolicy(Channel channel, string connectId)
        {
            this.connectId = connectId;
            this.channel = channel;
        }
        /// <summary>
        /// 一般网络错误时
        /// Called when [exception].
        /// </summary>
        /// <param name="e">The e.</param>
        public void OnNetworkError(Exception e)
        {
            channel.ConnectionManager.OnNetworkError(e);
        }
        /// <summary>
        /// 连接服务器错误时
        /// </summary>
        /// <param name="e"></param>
        public void OnConnectServerError(Exception e)
        {
            channel.ConnectionManager.OnConnectServerError(e);
        }
        /// <summary>
        /// 连接服务器成功后
        /// Called when [connected].
        /// </summary>
        public void OnConnected()
        {
            channel.ConnectionManager.OnConnectSuccessfully();
        }
    }
}
